var login_api = {
    adminLogin: "http://api.fangchepingtai.com/fangchebbs/admin/login",
    // adminLogin: "http://127.0.0.1:1333/fangchebbs/admin/login",
    adminLoginer: "http://api.fangchepingtai.com/fangchebbs/admin/loginer"
};
(function() {
    // 更改登陆类型
    // App.set("$Event.login.changeLoginType", function() {
    //     App.set("$Cache.login.logintype", !App.get("$Cache.login.logintype"));
    // });
    App.set("$Cache.login.logintype", true);
    Path.on(["/__basename__.html", ""], function(_current_location) {
        console.log('hehehe')
            // 用户登陆
        App.set("$Event.login.login", function() {
            var login_url = login_api.login;
            var logintype = App.get("$Cache.login.logintype");
            logintype ? login_url = login_api.adminLogin : false;
            console.log(logintype)
            var data = App.get("$Cache.login.info");
            coAjax.post(login_url, data, function(result) {
                console.log(result);
                if (result) {
                    result.type == "admin" ? App.set("admin", result) : (App.set("loginer", result), Cookies.set("loginer", result._id, { expires: 1000 * 60 * 60 * 24 }));
                    result.type == "admin" ? Path.jump("/admin/main.html") : Path.jump("/user/main.html");
                    // result.type == "admin" ? Path.jump("/admin/main.html") : Path.jump("/main.html");
                };
            }, function(error, errMsg) {
                console.log(error);
                console.log(errMsg);
            });
        });
    });
}());
